Developer Documentation
PATH  Mac OS X Documentation > Developer Tools > Mac OS X Assembler Guide


Previous | Contents | Next

Directives for Dealing with Symbols

This section describes directives that have an effect on symbols and the symbol table.

.globl

SYNOPSIS

.globl symbol_name

The .globl directive makes symbol_name external. If symbol_name is otherwise defined (by .set or by appearance as a label), it acts within the assembly exactly as if the .globl statement were not given; however, the link editor may be used to combine this object module with other modules referring to this symbol.

EXAMPLE

.globl abs .set abs,1  .globl var var: .long 2

.indirect_symbol

SYNOPSIS:

.indirect_symbol symbol_name

The .indirect_symbol directive creates an indirect symbol with symbol_name and associates the current location with the indirect symbol. An indirect symbol must be defined immediately before each item in a symbol_stub, lazy_symbol_pointers, and non_lazy_symbol_pointers section. The static and dynamic linkers use symbol_name to identify the symbol associated with the following item.

.reference

SYNOPSIS

.reference symbol_name

The .reference directive causes symbol_name to be an undefined symbol that will be present in the output's symbol table. This is useful in referencing a symbol without generating any bytes to do it (used, for example, by the Objective C run-time system to reference superclass objects).

EXAMPLE

.reference .objc_class_name_Object

.private_extern

SYNOPSIS:

.private_extern symbol_name

The .private_extern directive makes symbol_name a private external symbol. When the link editor combines this module with other modules (and the - keep_private_externs command-line option is not specified) the symbol turns it from global to static .

.lazy_reference

SYNOPSIS

.lazy_reference symbol_name

The .reference directive causes symbol_name to be a lazy undefined symbol that will be present in the output's symbol table. This is useful in referencing a symbol without generating any bytes to do it (used, for example, by the Objective C run-time system with the dynamic linker to reference superclass objects but to allow the runtime to bind them on first use).

EXAMPLE

.lazy_reference .objc_class_name_Object

.stabs, .stabn, and .stabd

SYNOPSIS

.stabs n_name ,n_type ,n_other ,n_desc ,n_value .stabn n_type ,n_other ,n_desc ,n_value .stabd n_type ,n_other ,n_desc

These three directives are used to place symbols in the symbol table for the symbolic debugger (a "stab" is a symbol table entry).

In each case, the n_type field is assumed to contain a 4.3BSD-like value for the N_TYPE bits. For .stabs and .stabn the n_sect field of the Mach-O file's nlist is set to the section number of the symbol for the specified n_value parameter. For .stabd the n_sect field is set to the current section number for the location counter. The nlist structure is defined in mach-o/nlist.h .

The n_other field of a stab directive is ignored.

EXAMPLE

.stabs "hello.c",100,0,0,Ltext
.stabn 192,0,0,LBB2
.stabd 68,0,15

.desc

SYNOPSIS

.desc symbol_name ,absolute_expression

The .desc directive sets the n_desc field of the specified symbol to absolute_expression .

EXAMPLE

.desc _main,0xface

.set

SYNOPSIS

.set symbol_name ,absolute_expression

The .set directive creates the symbol symbol_name and sets its value to absolute_expression . This is the same as using symbol_name =absolute_expression .

EXAMPLE

.set one,1 two = 2

.lsym

SYNOPSIS

.lsym symbol_name ,expression

A unique and otherwise unreferenceable symbol of the ( symbol_name , expression ) pair is created in the symbol table. Some Fortran 77 compilers use this mechanism to communicate with the debugger.


Mac OS X Assembler Guide: ASM Directives

Previous | Contents | Next